package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.dto.GoodsSalesDTO;
import com.sky.dto.OrdersConfirmDTO;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.dto.OrdersRejectionDTO;
import com.sky.entity.Orders;
import com.sky.vo.SalesTop10ReportVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * @Author 鹏少
 * @Date 2023/9/19
 * @Date 11:19
 */
@Mapper
public interface OrderMapper {
    void insert(Orders order);

    Page<Orders> page(OrdersPageQueryDTO ordersPageQueryDTO);

    @Select("select * from orders where id=#{id}")
    Orders selectById(Long id);


    void update(Orders orders1);

    @Select("select count(*) from orders where status = #{status}")
    Integer statusCount(Integer confirmed);

    @Update("update orders set status=#{status} where id=#{id}")
    void confirm(OrdersConfirmDTO ordersConfirmDTO);

    @Select("select * from orders where number = #{orderNumber} and user_id= #{userId}")
    Orders getByNumberAndUserId(String orderNumber, Long userId);


    @Select("select * from orders where status=#{status} and order_time<#{endTime}" )
    List<Orders> getByStatusAndOrdertime(Integer status, LocalDateTime endTime);

    Double getTurnoverSum(Integer status, LocalDateTime beginTime, LocalDateTime endTime);

    Integer getOrdersStatistics(Map map);

    List<GoodsSalesDTO>  selectTopTen(LocalDateTime beginTime, LocalDateTime endTime);

}
